<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/include/common-base.jsp"%>
  <title>动态表单-字段设计器</title>
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  
  <!-- left start -->
  <%@include file="/common/plateform/left.jsp" %>
  <!-- left end-->

  <!-- Main start -->
  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12 ibox">
        
          <!--搜索  start -->
          <div class="box box-info">
          
             <!--搜索title  start    -->
			  <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 字段搜索</h3>
                 <div class="box-tools pull-right">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>

            <!--搜索title  end -->
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="doCode" value="dymicSql"/>
				<input type="hidden" name="modelTypes" value="s_metadata"/>
				<c:if test="${empty database_type || database_type=='oracle'}">
				<input type="hidden" name="orderBy" value="to_number(metadata.reserved1),metadata.data_attr"/>
				</c:if>
				<c:if test="${not empty database_type && database_type=='mysql'}">
					<input type="hidden" name="orderBy" value="cast(metadata.reserved1 as unsigned int),metadata.data_attr"/>
				</c:if>
			    <input type="hidden" name="metadata.w_sortId" value="${param.sortCode}"/>
				  <div class="form-group">
					  <div class="col-sm-2 text-right"><label class="control-label">字段名称：</label></div>
					  <div class="col-sm-4">
						  <input type="text" class="form-control clean"  name="metadata.wl_dataShortName" value=""/>
					  </div>
					  <div class="col-sm-2 text-right"><label class="control-label">Java属性名：</label></div>
					  <div class="col-sm-4">
						  <input type="text" class="form-control clean"  name="metadata.wl_dataAttr" value=""/>
					  </div>
				  </div>
				  <center>
					  <div class="box-footer clearfix">
						  <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-search"></i> 查询</button>&nbsp;
						  <button type="button" class="btn btn-warning" onclick="FormUtil.cleanData('searchForm');">重置 </button>
					  </div>
				  </center>
			  </form>
			  <form id="inputForm" name="inputForm" method="post" >
			  
			<input type="hidden" name="formToken" id="formToken" value="${formToken}"/>
			<input type="hidden" name="tempIds" value="${param.sortCode}"/>
			<input type="hidden" name="createTemplate" value="1"/>
			<table class="table table-bordered " style="display: none;">
			<tr>
				<th style="width:120px;">生成地址<font color="red">*</font></th>
				<td><div class="col-sm-12">
					<input id="filePath" name="filePath"  value="" class="form-control"/>
					<br/>
					如：plateform/admin/${param.sortCode}
					</div>
				</td>
				<th>工程名<font color="red">*</font></th>
				<td><div class="col-sm-12">
					<input name="projectName" id="projectName" value="plateform" class="form-control"/>
					</div>		
				</td>
			</tr>
			<tr>
				<th>使用模板<font color="red">*</font></th>
				<td><div class="col-sm-12">
					<input name="templateName" id="templateName" class="form-control" value="coding/pages/objname-list.inc"/>
					</div>		
				</td>
				<td colspan="2">
					<button  onclick="createProject();" class="btn btn-danger" type="button">
				       	  <i class="fa fa-flag-o"></i> 生成代码
				       	</button>
				</td>
			</tr>
			 <%--<tr><th>工程名<font color="red">*</font></th>
				<td><div class="col-sm-8">
                        <input type="radio" name="createTemplate" value="1" checked="checked">页面
                          <input type="radio" name="createTemplate" value="0" checked="checked">全部
                        <input type="radio" name="createTemplate" value="2">配置文件
                        <input type="radio" name="createTemplate" value="3">action
                        <input type="radio" name="createTemplate" value="4">entity
                        <input type="radio" name="createTemplate" value="5">其他
                       </div>
		       </td></tr> --%>
		</table>
	</form>
            </div>
	     </div>
	     <!-- 搜索 end -->
        
        
        <div class="box box-success">
        
            <!--列表title  start --> 
	        <div class="box-header with-border">
                 <h3 class="box-title">
                 <i class="fa fa-table" onclick="javascript:void('-1')"></i> ${param.tableName}表字段管理 [sortCode=${param.sortCode}]
                       <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 增加字段 </button>
                       <button  onclick="toBack('${ctx}/sendPage/plateform/admin/sort/objName-table');" class="btn btn-primary" type="button"><i class="fa fa-reply"></i> 返回</button>
                 </h3>
                 <div class="box-tools pull-right">
	                 　　　　　　　　
                 </div>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body">
              <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                  <th>字段名称</th>
                  <th>字段描述</th>
                  <th>物理类型</th>
                  <th>Java属性名</th>
                  <th>主键</th>
                  <th>插入</th>
                  <th>编辑</th>
                  <th>列表</th>
                  <th>查询</th>
                  <th>排序</th>
                  <th>实体</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
            
          </div>
        </div>
      </div>
   
    
    <div class="modal fade" id="my_modal"  role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">
							<font color="red">添加/修改</font>&nbsp;
						</h4>
					</div>
					<div class="modal-body">
				
					   <form class="form-horizontal" role="form" id="submitForm">
					   		
					   		<!-- 隐藏域 start -->
							<input type="hidden" name="formToken" id="formToken" value=""/>
							<input type="hidden" id="w_metadataId" name="metadataId"  value=""/>
							<input type="hidden" name="sortId" value="${param.sortCode}"/>
							<input type="hidden" name="sysName" value="${param.sysName}"/>
					         <!-- 隐藏域 end -->
					         
					        <div class="box-body" id="submitFormData">
					        
					          	<!-- 属性循环体 start -->
				                <div class="form-group">
				                  <div class="col-sm-12 bg-success">基本配置</div>
				                </div>
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>字段名称</label>
				                  <div class="col-sm-4">
				                    <input type="text" id="dataShortName" name="dataShortName" onchange="setdataShortName()" class="form-control clean"  >
				                  </div>
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>字段描述</label>
				                  <div class="col-sm-4">
				                    <input type="text" id="dataFullName" name="dataFullName" class="form-control clean" maxlength="30" placeholder="输入中文描述" />
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>Java属性名称</label>
				                  <div class="col-sm-4">
				                    <input type="text" id="dataAttr" name="dataAttr" class="form-control clean" maxlength="20" placeholder="Java驼峰命名规则，如字段[user_name]就填写[userName]" >
				                  </div>
				                   <label class="col-sm-2 control-label" >是否实体字段</label>
				                  <div class="col-sm-4">
				                  	<select name="reserved2" id="reserved2" class="form-control">
				                    	  <option value="T" selected="selected">是</option>
										  <option value="F">否</option>
				                    </select>
				                    <div class="f12 red"><i class="fa fa-info-circle"></i> 当虚拟字段时才选择【否】</div>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>数据类型</label>
				                  <div class="col-sm-4">
				                    <select  name="dataType" id="dataType" class="form-control">
				                       <option value="5" selected="selected">字符-varchar2（推荐）</option>
									   <option value="1">整型-NUMBER</option>
									   <option value="2">长整型-NUMBER</option>
									   <option value="3">小数-NUMBER</option>
									   <option value="4">字节-CHAR</option>
									   <option value="6">日期-DATE</option>
				                    </select>
				                  </div>
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>数据长度</label>
				                  <div class="col-sm-4">
				                    <input type="text" data-name="dataLength" id="dataLength" name="dataLength" class="form-control clean" maxlength="50" value="50"  placeholder="必须是数字"/>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" ><font color="red">*</font>数据约束</label>
				                  <div class="col-sm-4">
				                    <select id="dataRestrict" name="dataRestrict" class="form-control">
				                    	  	<option value="3" selected="selected">可空</option>
					   						<option value="1">主键</option>
					   						<option value="2">非空</option>
				                    </select>
				                  </div>
				                   <label class="col-sm-2 control-label" >字段顺序</label>
				                  	<div class="col-sm-4">
				                    <input type="text"  name="reserved1" id="reserved1" class="form-control clean" maxlength="100" placeholder="必须是数字"/>
				                  	</div>
				                </div>
				                
				                
				                <div class="hidden">
				                <div class="form-group">
				                  <div class="col-sm-12 bg-success">扩展配置</div>
				                </div>
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" >允许插入</label>
				                  <div class="col-sm-4">
				                    <select id="ifAdd" name="ifAdd"  class="form-control">
				                    	  <option value="">--请选择--</option>
				                    	  <option value="T" selected="selected">是</option>
										  <option value="F">否</option>
				                    </select>
				                  </div>
				                  <label class="col-sm-2 control-label" >允许编辑</label>
				                  <div class="col-sm-4">
				                    <select id="ifEdit" name="ifEdit"  class="form-control">
				                    	  <option value="">--请选择--</option>
				                    	  <option value="T" selected="selected">是</option>
										  <option value="F">否</option>
				                    </select>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" >允许列表</label>
				                  <div class="col-sm-4">
				                    <select name="ifList" id="ifList"  class="form-control">
				                    	  <option value="">--请选择--</option>
				                    	  <option value="T">是</option>
										  <option value="F" selected="selected">否</option>
				                    </select>
				                  </div>
				                  <label class="col-sm-2 control-label" >允许查询</label>
				                  <div class="col-sm-4">
				                  	<select name="ifSearch" id="ifSearch" class="form-control">
				                    	  <option value="">--请选择--</option>
				                    	  <option value="T">是</option>
										  <option value="F" selected="selected">否</option>
				                    </select>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" >输入类型</label>
				                  <div class="col-sm-4">
				                    <select id="colmunType" onchange="changeColmunType(this)" name="colmunType" class="form-control">
				                    	  <option value="input" selected="selected">input-输入框</option>
				                    	  <option value="inputHidden" >input-隐藏域</option>
										  <option value="radio">radio-单选</option>
										  <option value="checkbox">checkbox-多选（未开放）</option>
										  <option value="select">select-下拉列表</option>
										  <option value="textarea">textarea-文本域</option>
										  <option value="date">date-日期文本框</option>
										  <option value="uploadimg">uploadimg-上传图片</option>
				                    </select>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" >请求URL</label>
				                  <div class="col-sm-10">
				                  	<input type="text" id="reqUrl"  name="reqUrl" maxlength="200" class="form-control  clean" placeholder="输入类型是 radio、checkbox、select 时必填" />
				                  	<div style="font-size:11px;color:red;">
				                  		案例1：doCode=dictItemList&cateEname=userType  ,案例2：doCode=dymicSql&modelTypes=s_trpCate
				                  	</div>
				                  </div>
				                </div>
				                
				                <div class="form-group">
				                  <label class="col-sm-2 control-label" >反显列</label>
				                  <div class="col-sm-10">
				                    <input type="text" id="resColmun" name="resColmun" class="form-control clean" maxlength="100" placeholder="请求URL参数涵 doCode=dymicSql 时必填" />
				                    <div style="font-size:11px;color:red;">
				                    	案例1：为空或{value:'itemValue',text:'itemText'} ,案例2：{value:'cateId',text:'cateName',other:'cateNo,cateType'}
				                    </div>
				                  </div>
				                </div>
				                </div>
				                <div class="form-group">
				                 
				                </div>
				                <!-- 属性循环体 end -->
				                
					        </div>
					        
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="saveInfo('submitForm');">提 交</button>
				            </div>
				            
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
    
 <div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font>&nbsp;
						</h4>
					</div>
					<div class="modal-body">
						
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
 
 
 <script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=(i+1)?>.<?=strUtil.doNull(rows[i].dataShortName,'')?></td>
				<td title="<?=rows[i].dataFullName?>"><?=strUtil.subStr(rows[i].dataFullName,5)?></td>
				<td><?=getColumType(rows[i].dataType,rows[i].dataLength)?></td>
				<td><?=strUtil.doNull(rows[i].dataAttr,'')?></td>
				<td><?=dataRestrictTxt(rows[i].dataRestrict)?></td>
				<td class="text_c"><?=checkedTxt(rows[i].ifAdd)?></td>
				<td class="text_c"><?=checkedTxt(rows[i].ifEdit)?></td>
				<td class="text_c"><?=checkedTxt(rows[i].ifList)?></td>
				<td class="text_c"><?=checkedTxt(rows[i].ifSearch)?></td>
				<td><?=strUtil.doNull(rows[i].reserved1,'')?></td>
				<td><?=strUtil.doNull(rows[i].reserved2,'')?></td>
				<td>
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].metadataId?>','edit')">修改</button> &nbsp;&nbsp;
					<?if(rows[i].dataRestrict==1){?>
						<span class='fx8 f10'>不可删</span>
					<?}else{?>
						<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].metadataId?>','<?=rows[i].sortId?>','<?=rows[i].dataFullName?>','<?=rows[i].dataShortName?>')">删除</button> 
					<?}?>
				</td>
			</tr>
		<?}?>
</script>
 
 <script>
var clickMenu = "objName-table";
var id,myPage,dataListId,searchFormId,isShowLog,objName,objId;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
objName = "metadata";
objId = "metadataId";
isShowLog = true;
$(function () {
	//1、加载分页列表数据
	getTableData();
	//2、控制是否启用token
	//setToken();
	
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
	DictUtil.getDictExtList("#proUnit", dictUrl, {cateEname:"productUnit"});
	DictUtil.getDataToSelect("#selectCate",{modelTypes:"s_trpCate"},{value:"cateId",text:"cateName",other:"cateNo,cateType"});
	
 });
 
 function getColumType(t,len){
	 var ctypeMap ={};
	 ctypeMap["5"]="varchar2";
	 ctypeMap["1"]="number";
	 ctypeMap["2"]="long";
	 ctypeMap["3"]="double";
	 ctypeMap["4"]="char";
	 ctypeMap["6"]="date";
	 return ctypeMap[t]+"("+len+")";
 }
 
 
//加载列表数据
 function getTableData(){
 	//alert(arguments[0]);
 	$.ajax({
 		   type:'get',
 		   url:common_list_url,
 		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
 		   dataType:'json',
 		   success: function(myData){
 		   if(isShowLog)console.log(myData);
 			var data = baidu.template(dataListId+"-template",eval(myData));  
 			$("#"+dataListId+"-body").html(data);
 			  var option= {
 					   ele:$("#"+dataListId+"-page")[0],
 					   total:myData.total,
 					   fn:getTableData,
 					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
 				   }
 				generatePages(option);
 		   }
 		});	
   }
//打开添加页面
function toAdd(){
	mytools.cleanData("submitFormData");//清空模态窗口内数据
	doAdd("my_modal");
}
//读取（查询、编辑）数据
function toLoad(id,type){
	var paramLoadData = {"metadata.w_metadataId":id,"modelTypes":"s_"+objName};
	loadObj(type,paramLoadData);
}

/**
 * 表单数据提交
 * @param formId
 */
function saveInfo(formId){
	var tableName = "${param.tableName}";
	tableName = transformStr3(tableName);
	var colName = $("#dataShortName").val();
	var attrName = tableName+"."+colName;
	var maxLength = 30;//默认按照oracle的最大列长度
	if("${database_type}"=="mysql"){
        maxLength = 64;
	}


	if(attrName.length>parseInt(maxLength)){
		layer.alert("设计字段时,【实体.字段名】不能超过【"+maxLength+"】个字符！");
		return;
	}
	var dataShortNameObj = $("#dataShortName");
	if(strUtil.isNull(dataShortNameObj.val())){
		layer.alert("字段名称不能为空！");
		return;
	}
	var dataFullNameObj = $("#dataFullName");
	if(strUtil.isNull(dataFullNameObj.val())){
		layer.alert("字段描述不能为空！");
		return;
	}
	var dataAttrObj = $("#dataAttr");
	if(strUtil.isNull(dataAttrObj.val())){
		layer.alert("属性名称不能为空！");
		return;
	} 
	var dataLengthObj = $("#dataLength");
	if(strUtil.isNull(dataLengthObj.val())){
		layer.alert("数据长度不能为空！");
		return;
	}
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:"${ctx}/info/saveMetadata",
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据操作成功");
		    		$("#my_modal").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	getTableData();
		  	}
		});	
	});
}
//反显数据
function showData(type,myData){
	console.log(myData);
	if("view"==type){
		FormUtil.loadView("", myData);
		
		doView("my_modal_view");
	}else if("edit"==type){
		//FormUtil.loadView(objName, myData);
		cleanData("submitFormData");
		
		DictUtil.checkSelectDict("#reserved2",myData.reserved2);
		FormUtil.fillData("#submitForm",myData,"id");
		
		doEdit("my_modal",myData.metadataId);
	}
}


function dataRestrictTxt(v){
	if(v=="1") return "主键";
	if(v=="2") return "非空";
	if(v=="3") return "可空";
	else v;
}
function checkedTxt(v){
	if(v=="T"){
		return "√";
	}else if (v=="F"){
		return "×";
	}else{
		return "";
	}
}
function createProject(){
	  var filePath = $("#filePath").val();
	  //var packPath = $("#packPath").val();
	  if(filePath==""){
		  alert("请填写工程生成地址");
		  return false;
	  }
	var sysName = $("#projectName").val();
	  if(sysName==""){
		  alert("请填写工程名");
		  return false;
	  }
	 
	  /*if(doNull(packPath)==""){
		  alert("请填写包路径");
		  return false;
	  }*/
	  var this_url ="${ctx}/common/coding/buildProject";
	  $.ajax({type:'post',url:this_url,data:$("#inputForm").serialize(),cache: false,async:false,dataType:'json',
		   success: function(myData){ alert(myData.msg); }
	  });
}

//逻辑删除
function toDele(id,sortId,fname,cname){
	//alert(id+"--"+sortId);
	var index_submit = layer.confirm("确定删除字段：["+fname+"-"+cname+"]吗？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramData = {"metadataId":id,sortId:sortId};
		$.ajax({
	    type:"get",
	    url:"${ctx}/info/delMetadata",
	    data: paramData,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	var result = myData.flag;
	    	if(result=="T"){
	    		//layer.alert("删除操作成功");
	    		refresh();
	    	}
	  	}
	});	
	});
}

function setdataShortName(){
	var dataShortName = $("#dataShortName").val();
	$("#dataAttr").val(transformStr3(dataShortName));
}

//字符串转成驼峰的方法
function transformStr3(str){
    var re=/_(\w)/g;
    return str.replace(re,function ($0,$1){
        return $1.toUpperCase();
    });
}


//设置模态框隐藏事件 
$( '#my_modal' ).on( 'show.bs.modal' ,function(e){  
	$.ajax({
	    type:'get',
	    url:ctx+'/sendPage/token?token=true',
	    dataType:'json',
	    success: function(myData){
	    	if(isShowLog)console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}); 

//打开添加页面
function doAdd(modalId){
	$("#w_"+objId).val("");
	$("#modelTypes").val("i_"+objName);
	$("#"+modalId).modal('show');
	
	mytools.cleanData("#submitFormData");//清空表单元素上次填写的内容；
	setValidate("#submitFormData");//定义add表单验证属性
	mytools.cleanValidate("#submitFormData");//清空上次校验规则提示
}

//打开修改页面
function doEdit(modalId,id){
	$("#modelTypes").val("u_"+objName);
	$("#w_"+objId).val(id);
	$("#"+modalId).modal("show");
}
//打开查看页面
function doView(modalId){
	$("#"+modalId).modal("show");
}
//获取对象值
function loadObj(type,paramData){
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	showData(type,myData);
	  	}
	});	
}

//删除信息（逻辑删除）
function doDele(paramData){
	$.ajax({
	    type:"post",
	    url:common_submit_url+"?doCode=dymicSql",
	    data: paramData,
	    dataType:"json",
	    success: function(myData){
	    	var result = myData.flag;
	    	if(result=="T"){
	    		layer.alert("删除操作成功");
	    		refresh();
	    	}
	  	}
	});	
}

/**
 * 表单数据提交
 * @param formId
 */
function save(formId){
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据保存成功");
		    		$("#my_modal").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	refresh();
		  	}
		});	
	});
}

//关闭win
function cannel(type){
	if(strUtil.isNull(type)){
		$('#my_modal').modal('hide');
	}else{
		$('#my_modal_'+type).modal('hide');
	}
}

function refresh(){
	getTableData();
}


function setToken(){
	$.ajax({
	    type:'get',
	    url:ctx+'/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}

function toBack(url){
	var page="${param.page}";
	if(page){
		sessionStorage.setItem("page",page);
	}
	mytools.pjax(url);
}

</script>   
   </section>
    <!-- Main end -->  
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/plateform/foot.jsp" %>
  <!-- foot start -->

 
</body>
	


</html>

